using System;
using Provausio.Common.Objects;
using TrainingManagement.api.Models.Data.CRUD;
using TrainingManagement.api.Models.Data.CRUD.Location;

namespace TrainingManagement.api.Models.BusinessLogic.Location
{
    public class LocationCreateOperation : BusinessOperation<BusinessObjects.Location, BusinessObjects.Location>
    {
        readonly LocationInsertDataSource _locationInsert = new LocationInsertDataSource();

        public override BusinessObjects.Location Run(BusinessObjects.Location input)
        {
            if (_locationInsert.Execute(input))
                return input;
            throw new Exception(string.Format("{0} was not saved!", input.Title));
        }
    }
}